#version 330 core
precision highp float;

uniform mat4 currentMaterial;
uniform sampler2D currentTexture;
uniform int useTexture;

in vec3 vertexPos;
in vec3 normalVec;
in vec2 texCoord;

in vec3 lightPos;
in vec3 eyePos;

out vec4 out_Color;

struct light
{
    vec3 position;
    vec3 diffuse;
    vec3 specular;
    vec3 ambient;
    float att;
    float kc;
    float kl;
    float kq;
    float d;
};

struct material
{
    vec3 diffuse;
    vec3 specular;
    vec3 ambient;
};


void main(void)
{     
        


//        light light1;
//        material material1;

//        vec3 eye = eyePos;

//        light1.diffuse = vec3(0.8,0.8,0.8);
//        light1.specular = vec3(0.3,0.3,0.3);
//        light1.ambient = vec3(0.2,0.2,0.2);
//        light1.kc = 0.8;
//        light1.kl = 0.1;
//        light1.kq = 0.1;

//        material1.diffuse = vec3(currentMaterial[0][0],currentMaterial[1][0],currentMaterial[2][0]);
//        material1.specular = vec3(currentMaterial[0][1],currentMaterial[1][1],currentMaterial[2][1]);
//        material1.ambient = vec3(currentMaterial[0][2],currentMaterial[1][2],currentMaterial[2][2]);
        
        
//        light1.position = lightPos;
//        vec3 lightDir =  light1.position -  vertexPos;
//        float distance = length(lightDir);
//        vec3 viewDir = eyePos - vertexPos;
//        vec3 n = normalize(normalVec);
//        float NdotL = max(dot(n,normalize(lightDir)),0.0);
//        float att = 1/(light1.kc + light1.kl*distance + light1.kq*distance*distance);
//        vec3 halfVector = normalize(vec3(lightDir + viewDir));
//        float shininess = pow(dot(n,halfVector),64);

//        vec3 color;
//        vec4 texColor = texture2D(currentTexture,texCoord);
//        if(useTexture==1){
//        color = vec3(((texColor.xyz * material1.diffuse)*light1.diffuse*NdotL)+ ((texColor.xyz * material1.specular)*light1.specular*shininess)
//            + ((texColor.xyz * material1.ambient)*light1.ambient)); }
//        else{ color = vec3((material1.diffuse*light1.diffuse*NdotL)+ (material1.specular*light1.specular*shininess)
//            + (material1.ambient*light1.ambient)); }
        
        //out_Color = vec4(1.0,0.0,0.0,1.0);
        //out_Color = texture2D(color_texture,tex_coord);
	gl_FragColor = glColor;
}

